package com.freeter.PropertiesUtil;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {

	private Properties prop = null;

	/**
	 * 初始化属性文件
	 * 
	 * @param fileName
	 * @return
	 */
	public PropertiesUtil(String fileName) {
		prop = new Properties();
		try {
			InputStream in = getClass().getResourceAsStream(fileName);
			prop.load(in);
			in.close();
		} catch (IOException e) {
			System.out.println("initialize properties file error! " + e);
		}
	}

	/**
	 * 读取值
	 * 
	 * @param fileName
	 * @param key
	 * @return
	 */
	public String getValue(String key) {
		return prop != null ? prop.getProperty(key) : "";
	}
}
